package com.slkj.shilixiaoyuanapp.entity.contacts;

import android.arch.persistence.room.Ignore;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.google.gson.Gson;

import java.util.List;

import static com.slkj.shilixiaoyuanapp.entity.code.UiCode.NO_CHOSE;

/**
 * Created  on 2018-08-22
 *
 * @author 唐开阔
 * @describe 通讯录具体的人-分组和具体联系人结合在一起
 */
public class ContactsPeopleEntity implements Parcelable {

    public static final int TYPE_GROUP = 1;
    public static final int TYPE_PEOPLE = 2;

    private String head;
    private String phone;
    protected boolean expand = false;
    private String name;
    private List<ContactsPeopleEntity> list;
    private Integer id ;
    private boolean isCheck;
    private int parent = 0;

    public int getParent() {
        return parent;
    }

    public void setParent(int parent) {
        this.parent = parent;
    }

    protected ContactsPeopleEntity(Parcel in) {
        head = in.readString();
        phone = in.readString();
        parent = in.readInt();
        expand = in.readByte() != 0;
        name = in.readString();
        list = in.createTypedArrayList(ContactsPeopleEntity.CREATOR);
        if (in.readByte() == 0) {
            id = null;
        } else {
            id = in.readInt();
        }
        isCheck = in.readByte() != 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(head);
        dest.writeString(phone);
        dest.writeInt(parent);
        dest.writeByte((byte) (expand ? 1 : 0));
        dest.writeString(name);
        dest.writeTypedList(list);
        if (id == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeInt(id);
        }
        dest.writeByte((byte) (isCheck ? 1 : 0));
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<ContactsPeopleEntity> CREATOR = new Creator<ContactsPeopleEntity>() {
        @Override
        public ContactsPeopleEntity createFromParcel(Parcel in) {
            return new ContactsPeopleEntity(in);
        }

        @Override
        public ContactsPeopleEntity[] newArray(int size) {
            return new ContactsPeopleEntity[size];
        }
    };



    public void setId(Integer id) {
        this.id = id;
    }

    public boolean isExpand() {
        return expand;
    }

    public void setExpand(boolean expand) {
        this.expand = expand;
    }

    public List<ContactsPeopleEntity> getList() {
        return list;
    }

    public void setList(List<ContactsPeopleEntity> list) {
        this.list = list;
    }

    public String getHead() {
        return head;
    }

    public void setHead(String head) {
        this.head = head;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public boolean isCheck() {
        return isCheck;
    }

    public void setCheck(boolean check) {
        isCheck = check;
    }


    public int getItemType() {
        return id == null ? TYPE_GROUP : TYPE_PEOPLE;
    }
}
